package com.asialjim.wechat.core.executor;

import com.asialjim.wechat.apiservice.Api;
import com.asialjim.wechat.apiservice.ApiRequest;
import com.asialjim.wechat.apiservice.executor.ApiExecutorBuilder;
import com.asialjim.wechat.core.api.BaseWeChatApi;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatApiExecutor ]</i></h2><strong>
 * <p> we-chat api executor
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email: <a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/3/2   &nbsp;&nbsp; JDK 8
 */
public interface WeChatApiExecutor {

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link Api api}
     * @param urlParam {@link ApiRequest.RequestUrlParam url param}
     * @param bodyParam {@link ApiRequest.RequestBodyParam body param}
     * @param responseClass {@link Class<T> response class}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/2 11:45
     */
    <T> T execute(BaseWeChatApi api, ApiRequest.RequestUrlParam urlParam, ApiRequest.RequestBodyParam bodyParam,Class<T> responseClass);

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link Api api}
     * @param urlParam {@link ApiRequest.RequestUrlParam url param}
     * @param responseClass {@link Class<T> response class}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:23
     */
    default <T> T execute(BaseWeChatApi api,ApiRequest.RequestUrlParam urlParam,Class<T> responseClass){
        return execute(api,urlParam,null,responseClass);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link Api api}
     * @param bodyParam {@link ApiRequest.RequestBodyParam body param}
     * @param responseClass {@link Class<T> response class}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/2 11:45
     */
    default <T> T execute(BaseWeChatApi api,ApiRequest.RequestBodyParam bodyParam,Class<T> responseClass){
        return execute(api,null,bodyParam,responseClass);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * <p> the executor will be created by {@link ApiExecutorBuilder}
     * @param api {@link Api api}
     * @param urlParam {@link ApiRequest.RequestUrlParam url param}
     * @param bodyParam {@link ApiRequest.RequestBodyParam body param}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/2 11:37
     */
    default <T> T execute(BaseWeChatApi api, ApiRequest.RequestUrlParam urlParam, ApiRequest.RequestBodyParam bodyParam){
        return (T) execute(api,urlParam,bodyParam,api.getResponseClass());
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link BaseWeChatApi we chat api}
     * @param apiRequest {@link ApiRequest api request}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:04
     */
    default <T> T execute(BaseWeChatApi api,ApiRequest apiRequest){
        return execute(api,apiRequest.getRequestUrlParam(),apiRequest.getRequestBodyParam());
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link BaseWeChatApi we chat api}
     * @param apiRequest {@link ApiRequest api request}
     * @param responseClass {@link Class response class}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:04
     */
    default <T> T execute(BaseWeChatApi api,ApiRequest apiRequest,Class<T> responseClass){
        return execute(api, apiRequest.getRequestUrlParam(),apiRequest.getRequestBodyParam(), responseClass);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link BaseWeChatApi we chat api}
     * @param responseClass {@link Class response class}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:05
     */
    default <T> T execute(BaseWeChatApi api,Class<T> responseClass){
        return execute(api,null,null,responseClass);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: execute ]</i></h3>
     * execute we-chat api
     * @param api {@link BaseWeChatApi we chat api}
     * @return {@link T response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:06
     */
    default <T> T execute(BaseWeChatApi api){
        return (T) execute(api,api.getResponseClass());
    }


    void setApplicationDomain(String applicationDomain);


    String getApplicationDomain();
}